package com.bawei.arouter

import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.callback.NavigationCallback

/**
 * Author: Jason Zhang
 * Date: 2024/4/26
 * Desc: 局部导航回调，实现局部降级策略
 */
class LocalNavigationCallBack constructor(private var path: String = ""): NavigationCallback {

    private var defaultPath: String = "/empty/activity"

    /**
     * 匹配到目标页面
     */
    override fun onFound(postcard: Postcard) {
        //可以做一些统计功能
    }

    /**
     * 未匹配到目标页面
     */
    override fun onLost(postcard: Postcard) {
        if(!path.isNullOrEmpty()){
            defaultPath = path as String
        }
        postcard.path = defaultPath
        postcard.navigation()
    }

    /**
     * 已经跳转到目标页面
     */
    override fun onArrival(postcard: Postcard) {
        //可以做一些统计功能
    }

    /**
     * 跳转拦截
     */
    override fun onInterrupt(postcard: Postcard) {
       //处理拦截业务
    }

}